<template>
  <div>
    <Form :model="data" :label-width="80">
      <FormItem label="商品名字">
        <Input v-model="data.name" placeholder="请输入商品名字"></Input>
      </FormItem>
      <FormItem label="商品编号">
        <Input v-model="data.goods_sn" placeholder="请输入商品编号"></Input>
      </FormItem>
      <FormItem label="商品分类">
        <Select v-model="data.category_id">
          <Option v-for="(item, ci) in cateList" :key="'cate' + ci">{{
            item.name
          }}</Option>
        </Select>
      </FormItem>
      <FormItem label="商品简介">
        <Input v-model="data.goods_desc" placeholder="请输入商品简介"></Input>
      </FormItem>

      <FormItem label="商品主图">
        <Ipload @getUrl="zz"></Ipload>
      </FormItem>
      <FormItem label="商品轮播">
        <Ipload @getUrl="za"></Ipload>
      </FormItem>

      <FormItem label="商品价格">
        <Input
          v-model="data.price"
          placeholder="请输入商品价格(单位:分)"
        ></Input>
      </FormItem>
      <FormItem label="划线价格">
        <Input
          v-model="data.pre_price"
          placeholder="请输入划线价格(单位:分)"
        ></Input>
      </FormItem>
      <FormItem label="是否热销">
        <Switch v-model="data.is_hot" />
      </FormItem>
      <FormItem label="是否最新">
        <Switch v-model="data.is_on_sale" />
      </FormItem>
      <FormItem label="全部销量">
        <Input
          v-model="data.month_sell_count"
          placeholder="请输入初始销量(默认0)"
        ></Input>
      </FormItem>
      <FormItem label="卖家备注">
        <Input v-model="data.seller_note" placeholder="请输入备注"></Input>
      </FormItem>
      <FormItem>
        
      </FormItem>
    </Form>
  </div>
</template>
<script>
import Ipload from "../components/Uploads.vue";
import { list, add, del } from "@/Api/goodsCate";
export default {
  components: {
    Ipload,
  },
  created() {
    list().then((res) => {
      this.cateList = res.data.data;
    });
  },
  data() {
    return {
      cateList: [],
      data: {
        _id: "",
        name: "",
        category_id: "",
        last_modify_date: "",
        goods_banner_imgs: [],
        add_date: "",
        keywords: "",
        is_new: true,
        orgin_price: "",
        is_real: true,
        remain_count: "",
        goods_desc: "",
        total_sell_count: "",
        is_best: true,
        seller_note: "",
        is_on_sale: true,
        month_sell_count: "",
        is_alone_sale: false,
        is_ho: false,
        price: "",
        price_desc: "",
        discount_price: "",
        goods_thumb: "",
        name: "",
      },
    };
  },
  props: {
    goods: {
      type: Object,
      default: null,
    },
  },
  methods: {
    zz(e) {
      this.data.goods_thumb = e
      // console.log(this.data.goods_banner_imgs);
    },
    za(e){
      this.data.goods_banner_imgs = e;
    },
  },
  watch:{
      data:{
        handler(newValue){
          this.$emit("value",newValue)
        },
        deep:  true,
      }
    }
};
</script>
<style>
</style>